package com.vf.admin.client.controller;

import com.vf.admin.client.common.ClientBaseController;
import com.vf.admin.client.service.AppUserService;
import com.vf.admin.client.service.ExpressionsCommonService;
import com.vf.admin.client.service.ExpressionsUserCustomService;
import com.vf.admin.common.entity.Result;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppMounts;
import com.vf.admin.miaodong.entity.ExpressionsCommon;
import com.vf.admin.miaodong.entity.ExpressionsUserCustom;
import com.vf.admin.utils.StringEx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 聊天常用语
 */
@RestController
@RequestMapping("/app/expressions")
public class AppExpressionsController extends ClientBaseController {

    @Autowired
    ExpressionsCommonService expressionsCommonService;
    @Autowired
    ExpressionsUserCustomService expressionsUserCustomService;

    /**
     * 常用语列表
     * @param sex 性别
     * @return
     */
    @RequestMapping(value = "/getList")
    public Result getMounts(Integer sex) {
        List<ExpressionsCommon> list = expressionsCommonService.list(sex);
        List<ExpressionsUserCustom> customList = expressionsUserCustomService.list(getUserId());

        list.addAll(ExpressionsCommon.buildEntity(customList));
        return sucessJSON(list);
    }

    @RequestMapping(value = "/add")
    public Result add(String content) {
        ExpressionsUserCustom params = new ExpressionsUserCustom();
        params.setUserId(getUserId());
        params.setContent(content);
        expressionsUserCustomService.saveOrUpdate(params);

        return sucessJSON("success");
    }

    @RequestMapping(value = "/del")
    public Result add(Integer id) {
        expressionsUserCustomService.del(getUserId(), id);
        return sucessJSON("success");
    }

}
